In the addon of the session, we calculated the distances to the closest hospitals located within North-Rhine Westphalia (NRW). Still, we did not show how to subset the original file, which contains all hospitals in Germany.
Subset the data file yourself by relying on the spatial information of the filehospital_points.csv and a polygon of NRW only. How
many hospitals are located within the borders of NRW?
hospital_points.csv in the ./data folder and
polygons of NRW. For the latter, you can again use the
osmdata syntax.
The default of sf::st_join() will leave you with a
‘left-join’ and returns a data object with all hospitals and matching
district information for those which are located within NRW. You can
reset the option to perform an ‘inner-join’ and keep only the
observation which lay within the predefined area
(sf::st_join(x , y, join = "", left = FALSE)).
Did the operationalization of health care provision convince you? Don’t you think it might be more important how many hospitals are close to survey respondents? To test this, we want to calculate the number of hospitals (and/or hospital beds) per district in North-Rhine Westphalia.
dplyr::as_tibble() data frame to use the
functions dplyr::group_by() and
dplyr::summarise().
dplyr::n() allows summarizing the total count
of hospitals. sum(beds) for summarizing the bed total per
district.